package mysql

import "gorm.io/gorm"

type RealName struct {
	gorm.Model
	UserId int64  `gorm:"type:int;unique;not null;" json:"user_id"`
	Name   string `gorm:"type:varchar(30);unique;not null;" json:"name"`
	IdCard string `gorm:"type:varchar(30);not null;" json:"id_card"`
}

func (r *RealName) FindRealNameByNameAndIdCard(userId int64, idCard string) error {
	err := DB.Where("user_id=? or id_card=?", userId, idCard).Find(&r).Error
	if err != nil {
		return err
	}
	return nil
}
func (r *RealName) CreateRealNameByNameAndIdCard() (err error) {
	err = DB.Create(&r).Error
	if err != nil {
		return err
	}
	return nil
}
